package fyp.spedmew.connector;

import android.os.AsyncTask;
import android.util.Log;

import java.io.IOException;

import fyp.spedmew.backend.entity.jobEndpoint.model.Job;

public class JobInsertATask extends AsyncTask<Job, Void, Long> {
    private static final String TAG = new Object(){}.getClass().getCanonicalName();

    @Override
    protected Long doInBackground(Job... params) {
        Long jobId = null;
        try {
            if (params.length > 0 && params[0] != null) {
                Job job = ApiService.getJobEndpoint().insertJob(params[0]).execute();
                jobId = job.getId();
            }
        } catch (IOException e) {
            Log.e(TAG, Log.getStackTraceString(e));
            jobId = null;
        }
        return jobId;
    }
}
